package com.elitecrm.saas.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.jdbc.core.JdbcTemplate;

public class CommonService extends AbstractService{
	private static final Log log = LogFactory.getLog(CommonService.class);
	public String callService(String param) throws Exception{
		Document doc = DocumentHelper.parseText(param);
		Element uuidEle = (Element)doc.selectSingleNode("/Root/UUID");
		if(uuidEle != null){
			String uuid = uuidEle.getText();
			String checkResultXML = checkUUID(uuid);
			log.debug("Check uuid result : "+checkResultXML);
			Document checkResultDoc = DocumentHelper.parseText(checkResultXML);
			String checkResult = checkResultDoc.selectSingleNode("/R/result").getText();
			if("1".equals(checkResult)){
				JdbcTemplate jt = new JdbcTemplate(getDataSource());
				
			}else{
				throw new EliteSAASException(EliteSAASException.INVAILD_UUID);
			}
		}else{
			throw new EliteSAASException(EliteSAASException.NO_UUID_FOUND);
		}
		return null;
	}
	
}
